// import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/css/reset.scss'
import api from './api/index'
import axios from 'axios'
// import { vueBaberrage } from 'vue-baberrage'
// import utils from '@/assets/js/utils.js'
Vue.prototype.$request = api
import utils from '@/assets/js/utils';
Vue.prototype.$utils = utils;
Vue.prototype.bus = new Vue()
// Vue.prototype.$utils = utils
// import VueHtml5Editor from 'vue-html5-editor'
// Vue.use(VueHtml5Editor, {name: "vue-html5-editor",showModuleName: false});
Vue.config.productionTip = false
// vue2.x  幸运抽奖插件LuckyWheel
import scroll from 'vue-seamless-scroll'
import VmScrollbar from 'vue-multiple-scrollbar'
Vue.use(scroll)
Vue.component(VmScrollbar.name, VmScrollbar)
// Vue.use(vueBaberrage)

import {
  Toast,
  Loading,
  Dialog,
  Uploader,
} from 'vant';
// 将所有 Toast 的展示时长设置为 2000 毫秒
Toast.setDefaultOptions({
  duration: 2000
});
// 将所有 loading Toast 设置为背景不可点击
Toast.setDefaultOptions('loading', {
  forbidClick: true
});

Vue.use(Toast).use(Loading).use(Dialog).use(Uploader);
//Vue.use(k-form-design);
//Vue.use(KFormDesign);
// //引入插件核心文件
// import VueQuillEditor from 'vue-quill-editor'
// //引入插件样式
// import 'quill/dist/quill.core.css'
// import 'quill/dist/quill.snow.css'
// import 'quill/dist/quill.bubble.css'

// Vue.use(VueQuillEditor);



// 添加请求拦截器
axios.interceptors.request.use(
  config => {
    Toast.loading({
      duration: 0, // 持续展示 toast
      message: '加载中...',
      loadingType: 'spinner',
    });
    return config // return是为了继续向下传递, promise链式传递
  },
  error => {
    return Promise.reject(error) // return Promise 是为了把错误继续向下传递
  })
// 拦截器2先执行
axios.interceptors.response.use(
  response => {
    // console.log('response',response)
    if (response.data.ret != 200) {
      // Toast(response.data.msg)
      Dialog.alert({
        title: '系统提示',
        message: response.data.msg,
      }).then(() => {
        // on close
      });
    }
    Toast.clear();
    return response
  },
  function (error) {
    // Toast.fail('加载失败！');
    Toast.clear();
    return Promise.reject(error)
  }
)

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')